package com.kelp.codetoolkit.provider

import com.intellij.openapi.fileEditor.FileEditor
import com.intellij.openapi.fileEditor.FileEditorPolicy
import com.intellij.openapi.fileEditor.FileEditorProvider
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.kelp.codetoolkit.editor.SpringConfigFileEditor
import org.jetbrains.annotations.NonNls

/**
 * @author: liuyuebai
 * @date: 2025/9/9 18:37
 * @description:
 */
class SpringConfigFileEditorProvider: FileEditorProvider, DumbAware {

    // 支持的文件类型：YML/YAML
    override fun accept(
        project: Project,
        file: VirtualFile
    ): Boolean {
       return file.extension in setOf("yml", "yaml", "properties")
    }

    override fun createEditor(
        project: Project,
        file: VirtualFile
    ): FileEditor {
        return SpringConfigFileEditor(project, file)
    }

    override fun getEditorTypeId(): @NonNls String {
        return "SpringConfigFileEditor"
    }

    override fun getPolicy(): FileEditorPolicy {
       return FileEditorPolicy.HIDE_DEFAULT_EDITOR
    }
}